package com.foo.common.base.service;

import java.io.Serializable;

import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.foo.common.base.dao.FooGenericDao;

@Service
@SuppressWarnings("unchecked")
@Transactional
public class FooGenericServiceImpl implements FooGenericService {

	@Autowired
	protected FooGenericDao fooGenericDao;

	protected Logger logger = LoggerFactory
			.getLogger(this.getClass().getName());

	@Override
	public Serializable save(Object entity) {
		return fooGenericDao.save(entity);
	}

	@Override
	public void update(Object entity) {
		fooGenericDao.update(entity);
	}

	@Override
	public void delete(Object object) {
		fooGenericDao.delete(object);

	}

	@Override
	public <T> T get(Class<T> clazz, Serializable id) {
		return (T) fooGenericDao.get(clazz, id);
	}

	@Override
	public SessionFactory getSessionFactory() {
		return fooGenericDao.getSession().getSessionFactory();
	}

	@Override
	public void saveOrUpdate(Object object) {
		fooGenericDao.saveOrUpdate(object);
	}

}
